package LeetcodeTest_tewnty_one;
//303.区域检索

public class sumRanges
{
    public static void main(String[] args)
    {
        int[] nu={-2, 0, 3, -5, 2, -1};
        NumArray obj1=new NumArray(nu);
        System.out.println(obj1.sumRange(0,2));
        System.out.println(obj1.sumRange(2,5));
        System.out.println(obj1.sumRange(0,5));
    }
}
class NumArray
{
    public int[] num;
    public NumArray(int[] nums)
    {
        this.num=nums;
    }
    public int sumRange(int i, int j)
    {
        int sum=0;
        while(i<=j)
        {
            sum+=num[i];
            i++;
        }
        return sum;
    }
}